<script setup>
import { Icon } from '@iconify/vue'

const prop = defineProps({
  name: {
    type: String,
    required: true,
  },
  className: {
    type: String,
    default: '',
  },
  color: {
    type: String,
    default: '',
  },
  /**
   * @readonly
   * @enum {'iconify','svg'}
   */
  type: {
    type: String,
    default: 'svg',
    validator: (value) => {
      return ['iconify', 'svg'].includes(value)
    },
  },
})

const svgClass = computed(() => {
  if (prop.className) {
    return `svg-icon ${prop.className}`
  }
  return 'svg-icon'
})
</script>

<template>
  <i>
    <Icon v-if="type === 'iconify'" :icon="name" />
    <svg v-if="type === 'svg'" :class="svgClass" aria-hidden="true">
      <use :xlink:href="`#icon-${name}`" :fill="color" />
    </svg>
  </i>
</template>

<style scope lang="scss">
.sub-el-icon,
.nav-icon {
  display: inline-block;
  font-size: 15px;
  margin-right: 12px;
  position: relative;
}

.svg-icon {
  width: 1em;
  height: 1em;
  position: relative;
  fill: currentColor;
  vertical-align: -2px;
}
.message-box-icon{
  width: 70px !important;
  height: 70px !important;
}
</style>
